<%@page import="java.util.Map"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.HashMap"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Lab Analysis page</title>
    <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" />
	<link rel="stylesheet" href="css/jquery-ui-1.10.3.css" />
	<link rel="stylesheet" href="css/AddDeleteUser.css" />
		<style type="text/css">
		.errors {
			background-color: #FFCCCC;
			border: 1px solid #CC0000;
			width: 400px;
			margin-bottom: 8px;
		}
		
		.errors li {
			list-style: none;
		}
		
		.welcome {
			background-color: #DDFFDD;
			border: 1px solid #009900;
			width: 200px;
		}
		
		.welcome li {
			list-style: none;
	}
	</style>
	
	<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="js/LabAnalysis.js"></script>
	<script src="js/jquery-ui-1.10.3.js"></script>
	
	<script type="text/javascript">

	$(document).ready(function(){
		
		$.mobile.ajaxEnabled = false;
		 $('#btnemail').bind('click',function(){
			 $('#emailBlock').toggle();
		 });

		 $('#btnsubmit').bind('click',function(){
			$('#Analysisform').attr('action','saveanalysis');
			 sessionStorage.isStored = 'false';
			 $('#Analysisform').submit(); 
		 });
		
		if(sessionStorage.isStored == 'true'){
			loadStorage();
		}
	});
	
	function clearSession(){
		sessionStorage.clear();
	}
	
	function storeToStorage(){
		sessionStorage.sandActual = $('#sandActual').val();
		sessionStorage.sandDiff = $('#sandDiff').val();
		sessionStorage.priceSubSand = $('#priceSubSand').val();
		sessionStorage.weight = $('#weight').val();
		sessionStorage.moistureActual = $('#moistureActual').val();
		sessionStorage.moistureDiff = $('#moistureDiff').val();
		sessionStorage.priceSubMoisture = $('#priceSubMoisture').val();
		sessionStorage.rate = $('#rate').val();
		sessionStorage.damageActual = $('#damageActual').val();
		sessionStorage.damageDiff = $('#damageDiff').val();
		sessionStorage.priceSubDamage = $('#priceSubDamage').val();
		sessionStorage.gross = $('#gross').val();
		sessionStorage.costUnload = $('#costUnload').val();
		sessionStorage.less = $('#less').val();
		sessionStorage.discount = $('#discount').val();
		sessionStorage.addDalali = $('#addDalali').val();
		sessionStorage.paidAdvance = $('#paidAdvance').val();
		sessionStorage.totalR = $('#totalR').val();
		sessionStorage.totalRebate = $('#totalRebate').val();
		sessionStorage.isStored = 'true';
	}

	function loadStorage(){
		 $('#sandActual').val(sessionStorage.sandActual);
		 $('#sandDiff').val(sessionStorage.sandDiff);
		 $('#priceSubSand').val(sessionStorage.priceSubSand);
		 $('#weight').val(sessionStorage.weight);
		 $('#moistureActual').val(sessionStorage.moistureActual);
		 $('#moistureDiff').val(sessionStorage.moistureDiff);
		 $('#priceSubMoisture').val(sessionStorage.priceSubMoisture);
		 $('#rate').val(sessionStorage.rate);
		 $('#damageActual').val(sessionStorage.damageActual);
		 $('#damageDiff').val(sessionStorage.damageDiff);
		 $('#priceSubDamage').val(sessionStorage.priceSubDamage);
		 $('#gross').val(sessionStorage.gross);
		 $('#costUnload').val(sessionStorage.costUnload);
		 $('#less').val(sessionStorage.less);
		 $('#discount').val(sessionStorage.discount);
		 $('#addDalali').val(sessionStorage.addDalali);
		 $('#paidAdvance').val(sessionStorage.paidAdvance);
		 $('#totalR').val(sessionStorage.totalR);
		 $('#totalRebate').val(sessionStorage.totalRebate);
		
	}
	/*function openEmailBlock(){
		
		$('#emailBlock').toggle();
	}
	
	function submitForm(){
		
		$('#Analysisform').submit();
	}
	*/
	function sendMail(){
		var inputs = $('input'); 
		$.each(inputs,function(key,val){
			 $(this).attr('value',($(this).val()));
		 });
		
		 $('#mailBody').val($('#emailContent').html());
		storeToStorage();
		$('#sendEmailAction').submit();
	}
	
	
	</script> 
	<script type="text/javascript" src="js/jquery.mobile-1.3.2.min.js"></script>
		
</head>

<body>
	<%
	HashMap  databarcodeMap = (HashMap)session.getAttribute("barcode"); 
	Iterator iterator = databarcodeMap.entrySet().iterator();
	String barcode = null;
	HashMap barcodedata = null;
	if(iterator.hasNext()){
		Map.Entry entry = (Map.Entry)iterator.next();
		barcode = (String)entry.getKey();
		barcodedata = (HashMap)entry.getValue();
	}
	 
	%>
	<div data-role="page" id="LabUser">
	
		<div data-position="fixed" data-role="header" align="center" data-theme="b">
		<a href="menudisplay" onclick="clearSession();" data-role="buttun" data-icon="home">Menu</a>	
			<div>&nbsp;</div>
			<div><h1>PARVATI SOLVENTS EXTRACTION PVT LTD</h1></div>
			<div><h3>GUT NO.76, KHADGAON,TALUKA: BADNAPUR,DISTRICT:JALNA-431203,MAHARASHTRA,INDIA</h3></div>  
		</div>
		<br>
		
			<div data-role="content">
				<s:if test="hasActionErrors()">
					<div class="errors">
						<s:actionerror />
					</div>
				</s:if>

				<form id="Analysisform" action="saveanalysis" method="post">
					<input type="hidden" name="barcode" value="<%=barcode%>" />
					<div>
					<div id="emailContent">
						<table border="1" align="center">
							<thead>
								<th colspan="6" align="center">PURCHASE VOUCHER</th>
							</thead>
							<tbody>
								<tr>
									<td width="10%" class="tableContentTitle"><label
										for="po_no" align="center"><b>PO NO.</b></label></td>
									<td width="15%"><input name="pono" class="textBoxClass"
										type="text" id="po_no" readonly="readonly"
										value="<%=barcodedata.get("businessPONo") %>" /></td>
									<td width="10%" class="tableContentTitle"><label
										for="broker" align="center"><b>Broker Name</b></label></td>
									<td width="15%" colspan="3"><input name="brockername"
										class="textBoxClass" type="text" id="broker"
										placeholder="Broker Name" readonly="readonly"
										value="<%=barcodedata.get("businessBrokerName") %>" /></td>
								</tr>
								<tr>
									<td width="10%" class="tableContentTitle"><label
										for="date" align="center"><b>Date</b></label></td>
									<td width="15%"><input name="datebusiness"
										class="textBoxClass" type="date" id="date"
										value="<%=barcodedata.get("businessdate") %>" /></td>
									<td width="10%" class="tableContentTitle"><label
										for="party" align="center"><b>Party Name</b></label></td>
									<td width="15%" colspan="3"><input name="partyname"
										class="textBoxClass" type="text" id="party"
										placeholder="Party Name" readonly="readonly"
										value="<%=barcodedata.get("businesscustomerName") %>" /></td>
								</tr>
								<tr>
									<td width="10%" class="tableContentTitle"><label
										for="commsionagnt" align="center"><b>Commision
												Agent</b></label></td>
									<td width="15%"><input name="commisionAgent"
										class="textBoxClass" type="text" id="commsionagnt"
										value="<%=barcodedata.get("commisionAgent") %>" /></td>
									<td width="10%" class="tableContentTitle"></td>
									<td width="15%" colspan="3"></td>
								</tr>
								<tr>
									<td width="10%" class="tableContentTitle"><label
										for="vehicle" align="center"><b>Vehicle</b></label></td>
									<td width="15%"><input class="textBoxClass" name="vehicle"
										type="text" id="vehicle" 
										readonly="readonly"
										value="<%=barcodedata.get("businessVehicleNo") %>" /></td>
									<td width="10%" class="tableContentTitle"><label
										for="address" align="center"><b>Address</b></label></td>
									<td width="15%" colspan="3"><input class="textBoxClass"
										name="address" type="text" id="address" placeholder="Address"
										readonly="readonly"
										value="<%=barcodedata.get("businessAddress") %>" /></td>
								</tr>
								<tr>
									<td width="10%" class="tableContentTitle"><label
										for="bags" align="center"><b>Bags</b></label></td>
									<td width="15%"><input class="textBoxClass" name="noofbag"
										type="number" id="bags"
										value="<%=barcodedata.get("businessNoOfBags") %>" /></td>
									<td width="10%" class="tableContentTitle"><label
										for="city" align="center"><b>City</b></label></td>
									<td width="15%" colspan="3"><input class="textBoxClass"
										name="city" type="text" id="city" placeholder="City"
										readonly="readonly"
										value="<%=barcodedata.get("businessCity") %>" /></td>
								</tr>
								<tr>
									<td rowspan="2" colspan="2" align="center"><b>SOYABEAN
											PURCHASE DETAILS REPORTS</b></td>
									<td colspan="4" align="center"><b>REPORTS</b>
								<tr>
									<td align="center"><b></b></td>
									<td align="center"><b>Actual %</b></td>
									<td align="center"><b>Excess %</b></td>
									<td align="center"><b>Rate Reduced</b></td>
								</tr>
								</td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Particulars</b></label></td>
									<td><input class="textBoxClass" name="comodity"
										type="text" id="particular" readonly="readonly"
										value="<%=barcodedata.get("businessCommodity") %>" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Sand/Silica</b></label></td>
									<td><input class="textBoxClass" name="sandActual"
										type="text" id="sandActual"
										value="<%=barcodedata.get("businessSandSilica") %>"
										pattern="^([0-9])*\.?([0-9])*$" /></td>
									<td><input class="textBoxClass" name="sandDiff"
										type="text" id="sandDiff" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
									<td><input class="textBoxClass" name="pricesand"
										type="text" id="priceSubSand" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Weight</b></label></td>
									<td><input class="textBoxClass" name="weight" type="text"
										id="weight"
										value="<%=barcodedata.get("businessNetWeight") %>"
										pattern="^([0-9])*\.?([0-9])*$" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Moisture</b></label></td>
									<td><input class="textBoxClass" name="moistureActual"
										type="text" id="moistureActual"
										value="<%=barcodedata.get("businessMoisture") %>"
										pattern="^([0-9])*\.?([0-9])*$" /></td>
									<td><input class="textBoxClass" name="moistureDiff"
										type="text" id="moistureDiff" value="0"
										pattern="^([0-9])*\.?([0-9])*$" /></td>
									<td><input class="textBoxClass" name="priceSubMoisture"
										type="text" id="priceSubMoisture" value="0"
										pattern="^([0-9])*\.?([0-9])*$" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Rate Per Unit</b></label></td>
									<td><input class="textBoxClass" name="rate" type="text"
										id="rate" value="0" pattern="^([0-9])*\.?([0-9])*$" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Damage Seeds</b></label></td>
									<td><input pattern="^([0-9])*\.?([0-9])*$"
										class="textBoxClass" name="damageActual" type="text"
										id="damageActual"
										value="<%=barcodedata.get("businessDamageSeeds") %>" /></td>
									<td><input pattern="^([0-9])*\.?([0-9])*$"
										class="textBoxClass" name="damageDiff" type="text"
										id="damageDiff" value="0" /></td>
									<td><input pattern="^([0-9])*\.?([0-9])*$"
										class="textBoxClass" name="pricesubdamage" type="text"
										id="priceSubDamage" value="0" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Gross Amount</b></label></td>
									<td><input class="textBoxClass" name="gross" type="text"
										id="gross" pattern="^([0-9])*\.?([0-9])*$" value="0" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Unloading Charges</b></label></td>
									<td></td>
									<td></td>
									<td><input class="textBoxClass" name="costunload"
										type="text" id="costUnload" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Less Rebate</b></label></td>
									<td><input class="textBoxClass" name="lessRebet"
										type="text" id="less" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Cash Discount</b></label></td>
									<td></td>
									<td></td>
									<td><input class="textBoxClass" name="discount"
										type="text" pattern="^([0-9])*\.?([0-9])*$" id="discount"
										value="0" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Add Dalali</b></label></td>
									<td><input class="textBoxClass" name="addDalali"
										type="text" id="addDalali" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Advance</b></label></td>
									<td></td>
									<td></td>
									<td><input class="textBoxClass" type="text" name="advance"
										id="paidAdvance" value="0" pattern="^([0-9])*\.?([0-9])*$" /></td>
								</tr>
								<tr>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Total Amount</b></label></td>
									<td><input class="textBoxClass" name="totalR" type="text"
										id="totalR" pattern="^([0-9])*\.?([0-9])*$" value="0" /></td>
									<td class="tableContentTitle"><label for="particular"
										align="center"><b>Total Rebate</b></label></td>
									<td colspan="2"></td>
									<td><input class="textBoxClass" name="totalRebet"
										type="text" id="totalRebate" pattern="^([0-9])*\.?([0-9])*$"
										value="0" /></td>
								</tr>
								<tr>
									<td colspan="6"><textarea rows="8"
											placeholder="Type your message"> </textarea></td>
								</tr>
							</tbody>
							
						</table>
						</div>
						<br>
						<div data-role="controlgroup" data-type="horizontal"
							align="center">
							<button type="button" id="calculate" value="Calculate"
								data-theme="a"></button>
							<input type="button" class="btnemail" id="btnemail"
								data-theme="a" value="Email"></input>
							<button type="button" class="btnsubmit" id="btnsubmit"
								data-theme="a" value="Submit"></button>
						</div>
					</div>
				</form>

			</div>
		
		<div id="emailBlock"  style="display: none;">
			 	<form action="sendEmail" method="post" id="sendEmailAction">
				   <label for="from">From</label><br/>
				   <input type="text" name="from"/><br/>
				   <label for="password">Password</label><br/>
				   <input type="password" name="password"/><br/>
				   <label for="to">To</label><br/>
				   <input type="text" name="to"/><br/>
				   <label for="subject">Subject</label><br/>
				   <input type="text" name="subject"/><br/>
				   
				   <input type="hidden" id="mailBody" name="body"/><br/>
				   <input type="button" onclick="sendMail()" value="Send Email"/>
				</form>
			</div>
	</div>
</body>
</html>